package com.wj.facedetect.broadcastreceiver;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.wj.facedetect.activity.alarm.AlarmDetailActivity;
import com.wj.facedetect.bean.im.PollingBean;
import com.wj.facedetect.commom.FaceDetectApplication;
import com.wj.facedetect.util.NotificationUtils;

/**
 * Created by wujing on 2018/4/12.
 */

public class AlarmPushBroadcastReceiver extends BroadcastReceiver {
    public static final String TAG = AlarmPushBroadcastReceiver.class.getName();

    @Override
    public void onReceive(Context context, Intent intent) {
        PollingBean.DataBean data = (PollingBean.DataBean) intent.getSerializableExtra("msg");
        if (data != null) {
            Log.e(TAG, "received in AlarmBroadcastReceiver" + data.getTemp());
            showNotifictionIcon(context, data.getWarningId() + "");
        }

    }

    public static void showNotifictionIcon(Context context, String message) {
        Intent intent = new Intent(context, AlarmDetailActivity.class);//将要跳转的界面
        intent.putExtra("message", message);
        PendingIntent intentPend = PendingIntent.getActivity(context, Integer.valueOf(FaceDetectApplication.getApplication().getRequestIndex() + ""), intent, PendingIntent.FLAG_CANCEL_CURRENT);
        new NotificationUtils(context).sendNotification("你有新的报警", "点击查看详细信息", intentPend);

    }
}

